﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.quest.Display.TaskFooters {
    import flash.events.*;
    import Display.DialogUI.*;
    import org.aswing.*;
    import Modules.minigames.*;
    import Display.aswingui.*;

    public class BeginMiniGame implements ITaskFooter {

        private var m_type:String;
        private var m_dialogView:GenericDialogView;
        private var btnStartGame:CustomButton;

        public function BeginMiniGame(_arg1:String, _arg2:GenericDialogView){
            this.m_type = _arg1;
            this.m_dialogView = _arg2;
            this.m_dialogView.addEventListener(Event.CLOSE, this.onDialogViewClose);
        }
        public function getComponent():Component{
            this.btnStartGame = new CustomButton(ZLoc.t("Quest", (this.m_type + "_start_btn_text")), null, "GreenButtonUI");
            this.btnStartGame.addActionListener(this.onButtonClick);
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            _local1.append(this.btnStartGame);
            if (((!(MiniGame.canStartMiniGame(this.m_type))) || (((MiniGame.getMiniGame()) && (MiniGame.getMiniGame().isActive()))))){
                this.btnStartGame.setEnabled(false);
            };
            return (_local1);
        }
        private function destroy():void{
            this.m_dialogView.removeEventListener(Event.CLOSE, this.onDialogViewClose);
            this.btnStartGame.removeActionListener(this.onButtonClick);
        }
        private function onButtonClick(_arg1:Event):void{
            MiniGame.start(this.m_type);
            this.m_dialogView.close();
        }
        private function onDialogViewClose(_arg1:Event):void{
            this.destroy();
        }

    }
}//package Modules.quest.Display.TaskFooters 
